<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>

        <ui:composition template="./template.xhtml">

            <ui:define name="title">
                Login
            </ui:define>

            <ui:define name="content">

                <c:if test="${user == null}">
                    <h2 class="art-postheader">Login Page
                    </h2>
                    <h:form>

                        <p:panelGrid id="display" columns="2">
                            <f:facet name="header">
                                Login page
                            </f:facet>
                            <h:outputText value="Username:" />
                            <p:inputText value="#{userController.username}" id="txtUsername" title="username" />
                            <h:outputText value="Password:" />
                            <h:inputSecret value="#{userController.password}" title="password"
                                           id="txtPassword" styleClass="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all"/>
                            <f:facet name="footer">
                                <p:commandButton id="btnLogin" ajax="false" action="#{userController.checkLogin}" value="Login"
                                                 oncomplete="home.show()" image="ui-icon ui-icon-check" />
                                <p:commandButton id="btnCancel" onclick="loginDialog.hide()" type="reset" image="ui-icon ui-icon-close" value="Cancel" />
                            </f:facet>

                        </p:panelGrid>
                    </h:form>
                </c:if>
                <c:if test="${user != null }">
                    <h2 class="art-postheader">User profile
                    </h2>
                    <li><span>
                            #{userController.current.userName}
                            <br/>
                            <h:outputText value=" #{userController.current.birthDay}">
                                <f:convertDateTime pattern="dd-MM-yyyy"/>
                            </h:outputText>
                            <br/>
                            #{userController.current.email}
                            <br/>
                            #{userController.current.phoneNumber}
                            <br/>
                            #{userController.current.addressInfo}

                        </span></li>
                    <li>
                        <h:form><h:commandLink id="lnkUserProfile" value="Profile" action="/UserProfile?faces-redirect=true" /></h:form>
                    </li>
                    <li>
                        <h:form><h:commandLink id="lnkUserProfile2" value="List Participte Event" action="/UserProfile?faces-redirect=true" /></h:form>
                    </li>

                </c:if>

            </ui:define>

        </ui:composition>

    </body>
</html>
